package com.cjg.Queue;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
//三大方法
public class pollDemo01 {
    public static void main(String[] args) {
     ExecutorService executor = Executors.newSingleThreadExecutor();//单个线程
//      ExecutorService executor =        Executors.newFixedThreadPool(3);//创建一个固定线程池大小为i
//        ExecutorService executor =      Executors.newCachedThreadPool();//课伸缩线程池
        try {
            for (int i = 0; i < 10; i++) {
            //使用线程池后使用新方法创建线程
            executor.execute(()->{
                System.out.println(Thread.currentThread().getName()+"::::::OK");
            });

        }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            executor.shutdown();
        }


    }
}
